.global _loader                 # making entry point visible to linker

# setting up the Multiboot header - see GRUB docs for details
.set ALIGN,    1<<0             # align loaded modules on page boundaries
.set MEMINFO,  1<<1             # provide memory map
.set FLAGS,    ALIGN | MEMINFO  # this is the Multiboot 'flag' field
.set MAGIC,    0x1BADB002       # 'magic number' lets bootloader find the header
.set CHECKSUM, -(MAGIC + FLAGS) # checksum required

.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM

# reserve initial kernel stack space
.set STACKSIZE, 0x4000          # that is, 16k.
.comm stack, STACKSIZE, 32      # reserve 16k stack on a quadword boundary

_loader:
   mov   $(stack + STACKSIZE), %esp # set up the stack
   push  %eax                       # Multiboot magic number
   push  %ebx                       # Multiboot data structure

   call  kmain            # call kernel proper
   hlt                    # halt machine should kernel retur

.global gdt_flush
gdt_flush:
lgdt (gp)
mov $0x10,%ax
mov %ax,%ds
mov %ax,%es
mov %ax,%gs
mov %ax,%fs
mov %ax,%ss
mov $0x28,%ax
ltr %ax
ljmp $0x8,$.flush_end
.flush_end:
ret

.global idt_flush

idt_flush:
lidt (idt_p)
ret

.global isr0
isr0: #function for dividing by zero
pusha
call div_zero
popa
iret # return from interrupt 

.global isr1
isr1:#debug exception
pusha
call debug_ex
popa
iret 

.global isr2
isr2:# nmi
pusha
call nmi
popa
iret

.global isr3
isr3: #breakpoint exception
pusha
call breakp_ex
popa
iret

.global isr4
isr4:#Into Detected Overflow Exception
pusha
call idoe_ex
popa
iret 

.global isr5
isr5:#Out of Bounds Exception
pusha
call outofb_ex
popa
iret 

.global isr6
isr6:#Invalid Opcode Exception
pusha
call invalop_ex
popa
iret 

.global isr7
isr7:#No Coprocessor Exception
pusha
call nocopr_ex
popa
iret 

.global isr8
isr8:#Double Fault Exception
pusha
call doufal_ex
popa
iret 

.global isr9
isr9:#Coprocessor Segment Overrun Exception
pusha
call copsego_ex
popa
iret 

.global isr10
isr10:#Bad TSS Exception
pusha
call badtss_ex
popa
iret 

.global isr11
isr11:#Segment Not Present Exception
pusha
call segnp_ex
popa
iret 

.global isr12
isr12:#Stack Fault Exception
pusha
call stkfal_ex
popa
iret 

.global isr13
isr13:#General Protection Fault Exception
pusha
call genpfe_ex
popa
iret 

.global isr14
isr14:#Page Fault Exception
pusha
call pagfal_ex
popa
iret 

.global isr15
isr15:#Unknown Interrupt Exception
pusha
call unkint_ex
popa
iret 

.global isr16
isr16:# Coprocessor Fault Exception 
pusha
call coproc_ex
popa
iret 

.global isr17
isr17:#Alignment Check Exception (486+)
pusha
call alignchk_ex
popa
iret 

.global isr18
isr18:#Machine Check Exception (Pentium/586+)
pusha
call macchk_ex
popa
iret 

.global isr32 
isr32: #timer isr
pusha
call timer_isr
popa
iret


 

